<?php

/**
 * ECSHOP 会员中心
 * ============================================================================
 * * 版权所有 2005-2012 上海商派网络科技有限公司，并保留所有权利。
 * 网站地址: http://www.ecshop.com；
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和
 * 使用；不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
 * $Author: liubo $
 * $Id: user.php 17217 2011-01-19 06:29:08Z liubo $
 */

define('IN_ECS', true);

require(dirname(__FILE__) . '/includes/init.php');
require(ROOT_PATH . 'includes/lib_order.php');

/* 载入语言文件 */
require_once(ROOT_PATH . 'languages/' .$_CFG['lang']. '/user.php');


define('SITE_URL','');
$smarty->assign('IMG_PATH',SITE_URL.'/images/pc/');
$smarty->assign('JS_PATH',SITE_URL.'/js/pc/');
$smarty->assign('CSS_PATH',SITE_URL.'/css/pc/');
$smarty->caching = false;

$user_id = $_SESSION['user_id'];
$action  = isset($_REQUEST['act']) ? trim($_REQUEST['act']) : 'default';

$affiliate = unserialize($GLOBALS['_CFG']['affiliate']);
$smarty->assign('affiliate', $affiliate);
$back_act='';
if($action=='login')
{

    $mobile = !empty($_POST['mobile']) ? $_POST['mobile'] : '';
    if(empty($mobile)){
        $mobile=$_SESSION['phone'];
    }
    $password = !empty($_POST['password']) ? $_POST['password'] : '';
    if (empty($mobile) || empty($password))
    {
        exit(returnFail('请正确输入手机号或密码'));
    }
    else
    {
        $info = $user->check_user($mobile, $password);
        if ($info['status'] == 'ok' )
        {
            $user->set_session($mobile);
            $user->set_cookie($mobile);
            exit(returnSuccess());
        }
        else
        {
            exit(returnFail($info['msg'],$info['type']));
        }
    }
    exit;
}
//注册
elseif($action=='register')
{
    include_once(ROOT_PATH . 'includes/lib_passport.php');
    $phone = isset($_POST['phone']) ? trim($_POST['phone']) : '';
    $password = isset($_POST['password']) ? trim($_POST['password']) : '';
    $code   = isset($_POST['code']) ? trim($_POST['code']) : '';
    $username   = isset($_POST['username']) ? trim($_POST['username']) : '';
    $info = $user->check_user($phone);
    if( !$info ) {
        $tag=false;
        if(!empty($_SESSION['sms_code_'.$phone])){
            foreach($_SESSION['sms_code_'.$phone] as $k=>$v) {
                if($code==$v) $tag=true;
            }
        }
        if( !$tag ) {
            print_r(returnFail('验证码错误', 'code_error'));
            exit;
        }
        if(strlen($password)<6)
        {
            exit(returnFail('密码不应小于6位', 'password_error'));
        }
        if (!$user->add_user($phone,$username, $password, '' )) {
            print_r(returnFail($GLOBALS['user']->error, 'reg_error'));
        }else{
            $user->set_session($phone);
            $user->set_cookie($phone);
            //if( $item_info ) $_SESSION['item_info'] = $item_info;
            //$id=$user->check_user($phone, $password);
            print_r(returnSuccess());
        }
    }else{
        print_r(returnFail('此手机号已经存在', 'isexist'));
    }
    exit;
}elseif($action=='resetpassword')
{
    include_once(ROOT_PATH . 'includes/lib_passport.php');
    $phone = isset($_POST['phone']) ? trim($_POST['phone']) : '';
    $password = isset($_POST['new_password']) ? trim($_POST['new_password']) : '';
    $repeat_password = isset($_POST['repeat_password']) ? trim($_POST['repeat_password']) : '';
    //$code   = isset($_POST['code']) ? trim($_POST['code']) : '';
//p($code);

    if(empty($phone)||!checkMobileFormat($phone))
    {
        exit(returnFail('请按流程在第一步输入手机号手机格式不正确','error_phone_format'));
    }
    $sql="select * from ".$ecs->table('users')." where phone='$phone'";
    $isExist=$db->getOne($sql);
    if(!$isExist)
    {
        exit(returnFail('此手机号不存在','phone_notisexist'));
    }
    if(mb_strlen($password)<6||mb_strlen($password)>32)
    {
        exit(returnFail('密码格式不正确','phone_notisexist'));
    }
    if($password!=$repeat_password)
    {
        exit(returnFail('两次密码输入不一致','phone_notisexist'));
    }


    $res=$user->change_password_by_phone($phone,$password);
    if($res['status'])
    {
        exit(returnSuccess());
    }
    exit(returnFail('修改失败'));
    if( !$info ) {
        $tag=false;
        if(!empty($_SESSION['sms_code_'.$phone])){
            foreach($_SESSION['sms_code_'.$phone] as $k=>&$v) {
                if($code==$v) {
                    $tag=true;
                }
            }
        }
        if( !$tag ) {
            print_r(returnFail('验证码错误', 'code_error'));
            exit;
        }
        if(str_len($password)<6)
        {
            exit(returnFail('密码不应小于6位', 'password_error'));
        }

        $data=array(
            'phone'=>$phone,
            'password'=>$password,
        );

    }else{
        print_r(returnFail('此手机号已经存在', 'isexist'));
    }
    exit;


    $data=array(
        'phone'=>$_SESSION['phone'],
        'password'=>$_POST['new_password'],
    );
    $res=$user->change_password_by_phone($_SESSION['phone'],$_POST['new_password']);
    if($res['status'])
    {
        exit(returnSuccess());
    }
    exit(returnFail('修改失败'));
}
else if($action=='send_sms_code')
{
    $phone=$_POST['phone'];
    if(empty($phone)||!checkMobileFormat($phone))
    {
        exit(returnFail('手机格式不正确','error_phone_format'));
    }

    $sql="select * from ".$ecs->table('users')." where phone='$phone'";
    $isExist=$db->getOne($sql);
    if($isExist)
    {
        exit(returnFail('此手机号已经存在','phone_isexist'));
    }
    $sms_url='http://wx.test.hfjy.red/gongkai/index.php?s=/addon/Api/Api/sendSMSCode/phone/'.$phone;
    $send_res=getCurl($sms_url);
    if($send_res['isok'])
    {
        $_SESSION['sms_code_'.$phone][]=$send_res['data']['code'];
        exit(returnSuccess());
    }
    exit(returnFail('验证码发送失败','send_fail'));
}else if($action=='reset_send_sms_code')
{
    $phone=$_POST['phone'];
    if(empty($phone)||!checkMobileFormat($phone))
    {
        exit(returnFail('手机格式不正确','error_phone_format'));
    }

    $sql="select * from ".$ecs->table('users')." where phone='$phone'";
    $isExist=$db->getOne($sql);
    if(!$isExist)
    {
        exit(returnFail('此手机号不存在','phone_notisexist'));
    }
    $sms_url='http://wx.test.hfjy.red/gongkai/index.php?s=/addon/Api/Api/sendSMSCode/phone/'.$phone;
    $send_res=getCurl($sms_url);
    if($send_res['isok'])
    {
        $_SESSION['sms_code_'.$phone][]=$send_res['data']['code'];
        exit(returnSuccess());
    }
    exit(returnFail('验证码发送失败','send_fail'));
}
else if($action=='logout')
{
    $user->logout();
    header('Location:/');exit;
    echo "<script>history.go(-1);</script>";exit;
}
else if($action=='reset_password_check_smscode')
{
    $phone = isset($_POST['phone']) ? trim($_POST['phone']) : '';
    $code   = isset($_POST['code']) ? trim($_POST['code']) : '';
    $tag=false;
    if(!empty($_SESSION['sms_code_'.$phone])){
        foreach($_SESSION['sms_code_'.$phone] as $k=>&$v) {
            if($code==$v) {
                $tag=true;
            }
        }
    }
    if( !$tag ) {
        print_r(returnFail('验证码错误', 'code_error'));
        exit;
    }
    exit(returnSuccess());
    exit;
}

// 不需要登录的操作或自己验证是否登录（如ajax处理）的act
$not_login_arr =
    array('login','act_login','register','act_register','act_edit_password','get_password','send_pwd_email','password', 'signin', 'add_tag', 'collect', 'return_to_cart', 'logout', 'email_list', 'validate_email', 'send_hash_mail', 'order_query', 'is_registered', 'check_email','clear_history','qpassword_name', 'get_passwd_question', 'check_answer');

/* 显示页面的action列表 */
$ui_arr = array('register', 'login', 'profile', 'order_list', 'order_detail', 'address_list', 'collection_list',
                'message_list', 'tag_list', 'get_password', 'reset_password', 'booking_list', 'add_booking', 'account_raply',
                'account_deposit', 'account_log', 'account_detail', 'act_account', 'pay', 'default', 'bonus', 'group_buy', 'group_buy_detail', 'affiliate', 'comment_list','validate_email','track_packages', 'transform_points','qpassword_name', 'get_passwd_question', 'check_answer');

/* 未登录处理 */
/*if (empty($_SESSION['user_id']))
{
    if (!in_array($action, $not_login_arr))
    {
        if (in_array($action, $ui_arr))
        {
            if (!empty($_SERVER['QUERY_STRING']))
            {
                $back_act = 'user.php?' . strip_tags($_SERVER['QUERY_STRING']);
            }
            $action = 'login';
        }
        else
        {
            //未登录提交数据。非正常途径提交数据！
            die($_LANG['require_login']);
        }
    }
}*/


/**
 * ----------------------------------------
 * |下面是需要登录的操作
 * ----------------------------------------
 */
if ( empty($_SESSION['user_id']))
{
    if(isset($_SERVER["HTTP_X_REQUESTED_WITH"]) && strtolower($_SERVER["HTTP_X_REQUESTED_WITH"])=="xmlhttprequest"){
        exit(returnFail('请登录','no_login'));
    }else{
        header('Location:/');exit;
    };

}else{
    $user_id=$_SESSION['user_id'];
}

/* 如果是显示页面，对页面进行相应赋值 */
if (in_array($action, $ui_arr))
{
    assign_template();
    $position = assign_ur_here(0, $_LANG['user_center']);
    $smarty->assign('page_title', $position['title']); // 页面标题
    $smarty->assign('ur_here',    $position['ur_here']);
    $sql = "SELECT value FROM " . $ecs->table('shop_config') . " WHERE id = 419";
    $row = $db->getRow($sql);
    $car_off = $row['value'];
    $smarty->assign('car_off',       $car_off);
    /* 是否显示积分兑换 */
    if (!empty($_CFG['points_rule']) && unserialize($_CFG['points_rule']))
    {
        $smarty->assign('show_transform_points',     1);
    }
    $smarty->assign('helps',      get_shop_help());        // 网店帮助
    $smarty->assign('data_dir',   DATA_DIR);   // 数据目录
    $smarty->assign('action',     $action);
    $smarty->assign('lang',       $_LANG);
}


//用户中心欢迎页
if ($action == 'default')
{

    include_once(ROOT_PATH .'includes/lib_clips.php');
    //where 条件
    $where_arr[]="user_id = '$user_id'";

    $sql="select order_status,count(*) count from ".$ecs->table('order_goods')." as order_goods left join ".$ecs->table('order_info')." as order_info on order_info.order_id=order_goods.order_id where ".join(' and ',$where_arr)." group by order_status";
    $orders_status_count=$db->getAll($sql);

    //全部订单
    $sql="select count(*) count from ".$ecs->table('order_info')." where user_id='$user_id'";
    $all_orders_count=$db->getOne($sql);
    //已经完成的订单
    $smarty->assign('all_orders_count',$all_orders_count);
    $sql="select count(*) count from ".$ecs->table('order_info')." where user_id='$user_id' AND pay_status=2";
    $finished_orders_count=$db->getOne($sql);

    $smarty->assign('finished_orders_count',$finished_orders_count);
    $sql="select count(*) count from ".$ecs->table('order_info')." where user_id='$user_id' AND pay_status in (0,1)";
    $payed_orders_count=$db->getOne($sql);
    $smarty->assign('payed_orders_count',$payed_orders_count);


    if(isset($_GET['pay_status']))
    {
        $pay_status=$_GET['pay_status'];
        if($pay_status!=2)
        {
            $where_arr[]="pay_status in (0,1)";
        }else{
            $where_arr[]="pay_status in (2)";
        }
        /*if($pay_status==0||$pay_status==1)
        {
            $where_arr[]="pay_status=".$pay_status;
            $smarty->assign('this_pay_status',$pay_status);
        }*/
    }
    $sql="select *,(select goods_thumb from ".$ecs->table('goods')." as goods where goods.goods_id=order_goods.goods_id) goods_thumb from ".$ecs->table('order_goods')." as order_goods left join ".$ecs->table('order_info')." as order_info on order_info.order_id=order_goods.order_id where ".join(' and ',$where_arr).' order by add_time desc';
    $orders=$db->getAll($sql);
    foreach($orders as $k=>&$v)
    {
        $v['goods_attr']=json_decode($v['goods_attr'],true);
        $v['add_time']=date('Y-m-d H:i:s',$v['add_time']);
    }
    $smarty->assign('orders',$orders);
    //
    $smarty->display('order_list.html');
}elseif($action=='changPassword')
{
    $phone=$_SESSION['phone'];
    $phone=substr($phone,0,3).'****'.substr($phone,7,11);
    $smarty->assign('phone',$phone);
    $smarty->display('change_password.html');exit;
}
//订单详情
elseif($action=='order_detail')
{
    $order_id=intval($_GET['order_id']);

    $sql="select * from ".$ecs->table('order_info')." as order_info left join ".$ecs->table('order_goods')." as order_goods using(order_id) left join ".$ecs->table('users')." as user using(user_id) where order_info.order_id='$order_id'";
    $order_detail=$db->getRow($sql);
    if(empty($order_detail)){
        echo "<script>alert('此订单不存在或已经删除');history.go(-1);</script>";exit;
    }
    foreach($order_detail as $k=>&$v)
    {
        if($k=='add_time'){
            $v=date('Y-m-d H:i:s',$v);
            $smarty->assign('make_order_time',date('m月d日 H:i',$v));
        }
        if($k=='pay_time')
        {
            $smarty->assign('pay_time',$v!=0?date('m月d日 H:i',$v):'');
        }
        if($k=='goods_attr'){
            $smarty->assign('goods_attr',json_decode($v));
        }

    }
    $smarty->assign('order_detail',$order_detail);
    $smarty->display('order_detail.html');exit;
}
//加入订单
elseif($action=='add_order')
{
    if(empty($_POST['goods_id'])||empty($_POST['goods_attr']))
    {
        exit(returnFail('请正确选择商品'));
    }
    $goods_attr=array_filter($_POST['goods_attr']);
    $_SESSION['goods'][$_POST['goods_id']]['goods_attrs']=$goods_attr;
    exit(returnSuccess());

}
elseif($action=='reset_password')
{
    $data=array(
        'phone'=>$_SESSION['phone'],
        'password'=>$_POST['new_password'],
    );

    $res=$user->change_password_by_phone($_SESSION['phone'],$_POST['new_password']);
   if($res['status'])
   {
       exit(returnSuccess());
   }
    exit(returnFail('修改失败'));
}
//确认订单
elseif($action=='confirm_order'){
    //$order_id=empty($_GET['order_id'])?0:$_GET['order_id'];
    //p($_GET);
    $goods_id=empty($_GET['goods_id'])?0:$_GET['goods_id'];
    $goods_attr_id=$_GET['goods_attr_id'];
    $sql="select * from ".$ecs->table('goods_attr')." goods_attr  left join ".$ecs->table('goods')." goods using(goods_id) where goods_attr_id='$goods_attr_id'";
    $goods=$db->getRow($sql);
    if(empty($goods))
    {
        $sql="select * from ".$ecs->table('goods')." where goods_id='$goods_id'";
        $goods=$db->getRow($sql);
        $goods['attr_price']=$goods['shop_price'];
    }

    if(empty($_SESSION['goods'][$goods_id]))
    {
        header("Location:goods.php");exit;
    }else{
        $amount=$goo=$goods['attr_price'];
        $goods_attrs=$_SESSION['goods'][$goods_id]['goods_attrs'];
    }
    $_SESSION['goods'][$goods_id]['price']=$goods['attr_price'];
    $amount=$goods['attr_price'];

    $goods_price=$amount;

    //是否是新用户
    $sql="select count(*) from ".$ecs->table('order_info')." where user_id='.$user_id.'";
    $order_count=$db->getOne($sql);
    $_SESSION['has_order']=$is_new=$order_count?true:false;
    $smarty->assign('is_new',$is_new);

    $sql="select email,user_name,qq,phone from ".$ecs->table('users')." where user_id='$user_id'";
    $user_info=$db->getRow($sql);

    $smarty->assign('user_info',$user_info);

    $smarty->assign('goods',$goods);
    $smarty->assign('goods_id',$goods_id);
    $smarty->assign('goods_attr',$goods_attrs);
    $smarty->assign('amount',$amount);

    $smarty->display('confirm_order.html');exit;



    $goods=get_goods_info($goods_id);
    $goods_price=$goods['shop_price'];
    $attrs_price=0;
    $goods_attrs=array();
    $goods_attr_id_str='';
    if(!empty($_POST['item_attrs']))
    {
        $item_attrs=join(',',$_POST['item_attrs']);
        $sql="select goods_attr.*,attr.attr_name from ".$ecs->table('goods_attr')." as goods_attr left join ".$ecs->table('attribute')." as attr on goods_attr.attr_id=attr.attr_id  where goods_attr_id in ($item_attrs)";
        $goods_attrs=$db->getAll($sql);

        foreach($goods_attrs as $k=>$v)
        {
            $attrs_price.=$v['attr_price'];
            $goods_attr_id_str.=$v['attr_id'].',';
        }
    }
    $amount=$goods_price+$attrs_price;




    //此订单不是本人提示订单不存在
    if($order_user_id!=$user_id)
    {
        echo "<script>alert('此订单不存在或已取消');history.go(-1);</script>";exit;
    }
    $sql="select *,(select goods_thumb from ".$ecs->table('goods')." goods where goods.goods_id=order_goods.goods_id) goods_thumb from ".$ecs->table('order_goods')." order_goods where order_id='$order_id'";

    $order_goods=$GLOBALS['db']->getRow($sql);
    $smarty->assign('order_goods',$order_goods);
    $smarty->assign('goods_attr',json_decode($order_goods['goods_attr'],true));
    $smarty->display('confirm_order.html');exit;
}else if($action=='change_linkman')
{
    $data=array();
    //$data['user_name']=$_POST['changeusername'];
    $data['qq']=$_POST['changeqq'];
    $data['email']=$_POST['changeemail'];
//p($_POST);
    /*if(!empty($data['email'])&&!filter_var($data['email'], FILTER_VALIDATE_EMAIL))
    {
        exit(returnFail('邮箱错误','email_error'));
    }*/

    $isok=$GLOBALS['db']->autoExecute($GLOBALS['ecs']->table('users'), $data, 'UPDATE',"user_id='$user_id'");
    if(!$isok)
    {
        exit(returnFail('用户信息修改失败','change_error'));
    }
    changeEmailByPhone($_SESSION['phone'],$data['email']);
    $_SESSION['user_name']=$data['user_name'];
    exit(returnSuccess($data));
}
elseif($action=='submit_order')
{
    $goods_id=!empty($_GET['goods_id'])?$_GET['goods_id']:0;
    if(empty($_SESSION['goods'][$goods_id]))
    {
        if($goods_id){
            header("Location:goods.php");exit;
        }else{
            header("Location:/");exit;
        }

    }

    $goods=get_goods_info($goods_id);
    $goods_price=$_SESSION['goods'][$goods_id]['price'];
    $goods_attr_id_str='';

    $amount=$goods_price;
    $sql="select email,user_name,qq,phone from ".$ecs->table('users')." where user_id='$user_id'";
    $user_info=$db->getRow($sql);
    //写入订单信息表
    $order = array(
        'order_sn'=>$order_sn=get_order_sn(), //获取新订单号
        'order_status'=>1,
        'user_id'=>$user_id,
        'goods_amount'=>$amount,
        'order_amount'=>$amount,
        'add_time'=>time(),
        'consignee'=>$user_info['user_name'],
        'tel'=>$user_info['phone'],
        'mobile'=>$user_info['phone'],
        'email'=>$user_info['email'],
        'add_time'=>time(),
        'confirm_time'=>time(),
    );
    $isok=$GLOBALS['db']->autoExecute($GLOBALS['ecs']->table('order_info'), $order, 'INSERT');
    if(!$isok)
    {
        echo "<script>alert('订单生成失败');history.go(-1);</script>";exit;
        exit(returnFail('订单生成失败','make_order_error'));
    }
    $order_id=$GLOBALS['db']->insert_id();
    $attrs_arr='';

    $attrs_str=json_encode($_SESSION['goods'][$goods_id]['goods_attrs']);
    $attrs_str=preg_replace("#\\\u([0-9a-f]+)#ie", "iconv('UCS-2', 'UTF-8', pack('H4', '\\1'))", $attrs_str);
    $sql="select goods_attr_id from ".$ecs->table('goods_attr')." where goods_id='$goods_id'";
    $goods_attrs_arr=$db->getAll($sql);
    $goods_attr_id_str='';
    foreach($goods_attrs_arr as $k=>$v)
    {
        $goods_attr_id_str.=$v['goods_attr_id'].',';
    }
    $order_goods=array(
        'order_id'=>$order_id,
        'goods_id'=>$goods['goods_id'],
        'goods_name'=>$goods['goods_name'],
        'goods_sn'=>$goods['goods_sn'],
        'goods_number'=>1,
        'market_price'=>$goods['market_price'],
        'goods_price'=>$amount,
        'goods_attr'=>$attrs_str,
        'goods_attr_id'=>$goods_attr_id_str
    );
    $isok=$GLOBALS['db']->autoExecute($GLOBALS['ecs']->table('order_goods'), $order_goods, 'INSERT');
    if(!$isok)
    {
        echo "<script>alert('商品订单生成失败');history.go(-1);</script>";exit;
        exit(returnFail('商品订单生成失败','make_order_error'));
    }

    unset($_SESSION['goods'][$goods_id]);
    header('Location:user.php?act=to_pay&order_id='.$order_id);exit;
    $smarty->display('submit_order_ok.html');exit;

}
elseif($action=='to_pay')
{
    $order_id=intval($_GET['order_id']);
    $user_id=intval($_SESSION['user_id']);
    $sql="select * from ".$ecs->table('order_info')." order_info left join ".$ecs->table('order_goods')." order_goods using(order_id) where order_goods.order_id='$order_id' and user_id='$user_id'";
    $order_info=$db->getRow($sql);
    if(empty($order_info)){
        header('Location:user.php');exit;
    }
    $goods_attr=json_decode($order_info['goods_attr'],true);
    $goods_desc='';
    foreach($goods_attr as $k=>$v)
    {
        $goods_desc.=$k.$v.';';
    }
    $smarty->assign('goods_desc',$goods_desc);
    $goods_name='海风课程';
    if(!empty($order_info['goods_name']))
    {
        $goods_name=$order_info['goods_name'];
    }
    $smarty->assign('order_id',$order_id);
    $smarty->assign('goods_name',$goods_name);
    $smarty->assign('nowtime',date('Y-m-d H:i:s',$order_info['add_time']+864000));
    $smarty->assign('order_sn',$order_info['order_sn']);
    $smarty->assign('order_amount',$order_info['order_amount']);
    $smarty->assign('order_info',$order_info);
    $smarty->display('comfirm_to_pay.html');
    exit;
}elseif($action=='pay_return'){
    $order_sn=$_GET['order_sn'];
    if(!empty($_SESSION['user_id']))
    {
        $user_id=$_SESSION['user_id'];
    }
    $user_id=$_SESSION['user_id'];
    $sql="select * from ".$ecs->table('order_info')." order_info where order_sn='$order_sn' and user_id='$user_id'";
    $order_info=$GLOBALS['db']->getRow($sql);
    $smarty->assign('order_id',$order_info['order_id']);
    if(empty($order_info)){
        echo "<script>alert('此订单不存在或已经删除');location.href='user.php'</script>";exit;
    }
  /*  if($order_info['pay_status'])
    {
        echo "<script>alert('请不要重复执行');location.href='user.php'</script>";exit;
    }*/
    if($order_info['pay_status'])
    {
        if(!$_GET['pay_status'])
        {
            echo "<script>alert('根据系统识别你已经成功支付订单，如遇问题请联系客服');";exit;
            $smarty->assign('pay_status',1);
        }else{
            $smarty->assign('pay_status',1);
        }
    }
    //修改付款状态

    /*$order_return=array(
        'pay_time'=>time(),
        'pay_status'=>1,
    );
    $isok=$GLOBALS['db']->autoExecute($GLOBALS['ecs']->table('order_info'), $order_return,'',"order_sn='$order_sn'");*/

    $smarty->assign('order_amount',$order_info['order_amount']);
    $smarty->assign('order_sn',$order_info['order_sn']);
    $smarty->display('pay_return.html');
}

exit;
